<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of edge_color</title>
  <meta name="keywords" content="edge_color">
  <meta name="description" content="edge_color(g,algo) --- find a proper edge coloring of the graph g">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">matgraph</a> &gt; <a href="index.html">@graph</a> &gt; edge_color.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph/@graph&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>edge_color
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>edge_color(g,algo) --- find a proper edge coloring of the graph g</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function c = edge_color(g,algo) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> edge_color(g,algo) --- find a proper edge coloring of the graph g
 The returned matrix has three columns. Each row of this matrix of the
 form [i j c] where ij is an edge of the graph and c is a color number
 (from 1 to the number of colors used). 
 
 algo denotes an algorithm. The choices are:

 greedy:    use a greedy coloring, based on the line graph (default)
 
 optimal:   create an optimal coloring, based on the line graph

 vizing:    create a coloring that uses at most max(deg(g))+1 colors
            NOTE: THIS IS UNIMPLEMENTED AT THIS TIME!</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="color.html" class="code" title="function p = color(g,algo,max_time)">color</a>	color(g,algo) --- color the graph g by a given algorithm</li><li><a href="edge_color.html" class="code" title="function c = edge_color(g,algo)">edge_color</a>	edge_color(g,algo) --- find a proper edge coloring of the graph g</li><li><a href="edges.html" class="code" title="function elist = edges(g)">edges</a>	edges(g) --- list the edges in g as a 2-column matrix</li><li><a href="free.html" class="code" title="function free(g)">free</a>	free(g) --- free the graph from the system</li><li><a href="graph.html" class="code" title="function g = graph(n)">graph</a>	graph: constructor for the graph class</li><li><a href="line_graph.html" class="code" title="function line_graph(g,h)">line_graph</a>	line_graph(g,h) --- set g to be the line graph of h</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="cdraw.html" class="code" title="function cdraw(g,coloring,line_style,color_matrix)">cdraw</a>	cdraw(g,coloring) -- draw g with a given vertex coloring</li><li><a href="draw.html" class="code" title="function draw(g,line_style)">draw</a>	draw(g) --- draw g in a figure window</li><li><a href="edge_color.html" class="code" title="function c = edge_color(g,algo)">edge_color</a>	edge_color(g,algo) --- find a proper edge coloring of the graph g</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function c = edge_color(g,algo)</a>
0002 <span class="comment">% edge_color(g,algo) --- find a proper edge coloring of the graph g</span>
0003 <span class="comment">% The returned matrix has three columns. Each row of this matrix of the</span>
0004 <span class="comment">% form [i j c] where ij is an edge of the graph and c is a color number</span>
0005 <span class="comment">% (from 1 to the number of colors used).</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% algo denotes an algorithm. The choices are:</span>
0008 <span class="comment">%</span>
0009 <span class="comment">% greedy:    use a greedy coloring, based on the line graph (default)</span>
0010 <span class="comment">%</span>
0011 <span class="comment">% optimal:   create an optimal coloring, based on the line graph</span>
0012 <span class="comment">%</span>
0013 <span class="comment">% vizing:    create a coloring that uses at most max(deg(g))+1 colors</span>
0014 <span class="comment">%            NOTE: THIS IS UNIMPLEMENTED AT THIS TIME!</span>
0015 
0016 <span class="keyword">if</span> nargin &lt; 2
0017     algo = <span class="string">'greedy'</span>;
0018 <span class="keyword">end</span>
0019 
0020 <span class="keyword">switch</span> (lower(algo))
0021     <span class="keyword">case</span> {<span class="string">'greedy'</span>,<span class="string">'optimal'</span>}
0022         h = <a href="graph.html" class="code" title="function g = graph(n)">graph</a>;
0023         <a href="line_graph.html" class="code" title="function line_graph(g,h)">line_graph</a>(h,g);
0024         p = <a href="color.html" class="code" title="function p = color(g,algo,max_time)">color</a>(h,algo);
0025         c = [<a href="edges.html" class="code" title="function elist = edges(g)">edges</a>(g), array(p)'];
0026         <a href="free.html" class="code" title="function free(g)">free</a>(h);
0027         
0028     <span class="keyword">case</span> <span class="string">'vizing'</span>
0029         warning(<span class="string">'edge_color:novizing'</span>,<span class="keyword">...</span>
0030             <span class="string">'The &quot;vizing&quot; algorithm is not implemented. Using greedy algorithm.'</span>)
0031         c = <a href="edge_color.html" class="code" title="function c = edge_color(g,algo)">edge_color</a>(g,<span class="string">'greedy'</span>);
0032         
0033     <span class="keyword">otherwise</span>
0034         error([<span class="string">'Unknown algorithm: '</span>, algo]);
0035 <span class="keyword">end</span></pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>